#include<iostream>
#include<cmath>
using namespace std;

int n,m,loong,vmax;
int csydis[100001];

struct cars{
        int dist;//ru kou
        int xdist;//lu chen
        int ar;//jia su du
        int vr;//chu su du
};

int main(){
        freopen("detect6.in","r",stdin);
        freopen("detect.out","w",stdout);
        cars car[100001];
        int tst0,add0 = 0,akk0 = 0;
        cin>>tst0;
        for(int w = 0;w < tst0;w++){
                cin>>n>>m>>loong>>vmax;
                for(int i = 0;i < n;i++){
                        cin>>car[i].dist>>car[i].vr>>car[i].ar;
                        car[i].xdist = loong - car[i].dist;
                        add0= add0 + car[i].ar;
                        if(car[i].vr > vmax) akk0++;
                }
                for(int i = 0;i < m;i++){
                        cin>>csydis[i];
                }

//                if(add0 == 0){
                        m = m - 1;
                        cout<<akk0<<" "<<m;
//                }
/*

                for(int i = 0;i < n;i++){
                                int s = 0;
                        while((car[i].ar > 0)||(car[i].xdist) > 0){
                                s++;
                                int swap0;
                                swap0 = car[i].vr;
                                car[i].vr = car[i].vr + car[i].ar * s;
                                car[i].xdist = car[i].xdist - ((car[i].vr + swap0) / 2);

                        }
                }
*/

        }




        return 0;
}
